package com.yanggu.mapreduce.reducejoin;

import lombok.Data;
import org.apache.hadoop.io.Writable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/**
 * @version V1.0
 * @author: YangGu
 * @date: 2020/2/7 21:05
 * @description:
 */
@Data
public class TableBean implements Writable {

    /**
     * 订单的id
     */
    private String id;

    /**
     * 品牌的id
     */
    private String pId;

    /**
     * 品牌的名称
     */
    private String pName;

    /**
     * 订单的数量
     */
    private Integer count;

    /**
     * 标记，用于区分来自哪张表的数据
     */
    private String flag;


    @Override
    public void write(DataOutput out) throws IOException {
        out.writeUTF(this.id);
        out.writeUTF(this.pId);
        out.writeUTF(this.pName);
        out.writeInt(this.count);
        out.writeUTF(flag);
    }

    @Override
    public void readFields(DataInput in) throws IOException {
        this.id = in.readUTF();
        this.pId = in.readUTF();
        this.pName = in.readUTF();
        this.count = in.readInt();
        this.flag = in.readUTF();
    }

    @Override
    public String toString() {
        return id + '\t' + pName + '\t'  + count;
    }
}
